package 尚硅谷.juc.test11;


public class ReadWriteLockDemo {

    public static void main(String[] args) {
        /**
         * 线程操作资源类
         */
        MyCache myCache=new MyCache();

        /**
         * 写入
         */
        for (int i=0;i<5;i++){
            final String temp=i+"";
            new Thread(()->{
                try {
                    myCache.put(temp,temp);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }

        /**
         * 读取
         */
        for (int i=0;i<5;i++){
            final String temp=i+"";
            new Thread(()->{
                try {
                    myCache.get(temp);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
        }

    }
}
